package com.caesar.Test;

import com.caesar.Practice_sealed.Animal;
import com.caesar.Practice_sealed.Cat;
import com.caesar.Practice_sealed.Dog;
import com.caesar.Practice_sealed.PetDog;

/**
 * @author caesar
 * @date 2025/7/11
 * @Description:
 * @apiNote
 */
public class TestAnimal {
    public static void main(String[] args) {
        Animal[] animals = new Animal[3];
        animals[0] = new Dog();
        animals[1] = new PetDog();
        animals[2] = new Cat();
        for (Animal animal : animals) {
            animal.eat();
            if(animal instanceof Dog d){
                d.watchHouse();
            }else if(animal instanceof Cat c){
                c.catchMouse();
            }
        }
    }
}
